﻿''' <summary>
''' tudo 暂时注释，等待修复
''' </summary>
Public Class DownLoadManagerForm
    Inherits Form

    'Public Sub New(ByVal Manager As BI.ExternalLib.FileService.DownLoadManager)

    '    ' 此调用是设计器所必需的。
    '    InitializeComponent()

    '    ' 在 InitializeComponent() 调用之后添加任何初始化。
    '    Me.NotifyIcon1.Text = Me.Text
    '    Me._Manager = Manager
    'End Sub

    'Public ReadOnly Property Manager As BI.ExternalLib.FileService.DownLoadManager
    '    Get
    '        Return _Manager
    '    End Get
    'End Property
    'Friend WithEvents _Manager As BI.ExternalLib.FileService.DownLoadManager

    'Private Sub FileService_DownloadProgressChanged(sender As Object, e As ExternalLib.FileService.DownloadProgressChangedEventArgs) Handles _Manager.DownloadProgressChanged
    '    Dim Item As BI.ExternalLib.FileService.DownLoadManager.Item = Manager.Current
    '    Dim row As  Marmat.Forms.Views.DataGrid.Row = Nothing
    '    For Each dr As  Marmat.Forms.Views.DataGrid.Row In Me.BDataGrid1.Rows
    '        If dr("Tag") Is Item Then
    '            row = dr
    '            Exit For
    '        End If
    '    Next
    '    Dim f As Object = Me.BDataGrid1.DataSource
    '    If row IsNot Nothing Then
    '        Dim jd As Decimal = e.BytesReceived / Item.TotalBytesToReceive
    '        row("Progress") = e.ProgressPercentage
    '        row.BaseRow.AcceptChanges()
    '    End If
    'End Sub

    'Private Sub FileService_DownloadDataCompleted(sender As Object, e As ExternalLib.FileService.AsyncCompletedEventArgs) Handles _Manager.DownloadDataCompleted
    '    Dim Item As BI.ExternalLib.FileService.DownLoadManager.Item = Manager.Current
    '    Dim row As  Marmat.Forms.Views.DataGrid.Row = Nothing
    '    For Each dr As  Marmat.Forms.Views.DataGrid.Row In Me.BDataGrid1.Rows
    '        If dr("Tag") Is Item Then
    '            row = dr
    '            Exit For
    '        End If
    '    Next
    '    If row IsNot Nothing Then
    '        row("State") = Item.State
    '        'row("Progress") = 100
    '        If e.Error IsNot Nothing Then
    '            row.BaseRow.SetColumnError("State", e.Error.Message)
    '        End If
    '        row.BaseRow.AcceptChanges()
    '    End If
    'End Sub

    'Private Sub FileManagerDoForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
    '    If e.CloseReason = CloseReason.UserClosing Then
    '        FileManager.DownLoadManager.CloseDownLoadForm()
    '        e.Cancel = True
    '    End If
    'End Sub

    'Private Sub NotifyIcon1_MouseDown(sender As Object, e As MouseEventArgs) Handles NotifyIcon1.MouseDown
    '    If e.Button = System.Windows.Forms.MouseButtons.Left Then
    '        If Me.Visible = False Then
    '            FileManager.DownLoadManager.ShowDownLoadForm()
    '        Else
    '            FileManager.DownLoadManager.CloseDownLoadForm()
    '        End If
    '    End If
    'End Sub

    'Private Sub BDataGrid1_CustomDrawCell(sender As Object, e As  Marmat.Forms.Views.DataGrid.RowCellCustomDrawEventArgs) Handles BDataGrid1.CustomDrawCell
    '    If e.RowHandle >= 0 AndAlso Me.BDataGrid1.Rows.Count > e.RowHandle Then
    '        Dim dr As  Marmat.Forms.Views.DataGrid.Row = Me.BDataGrid1.Rows(e.RowHandle)
    '        Dim dt As System.Data.DataTable = Me.BDataGrid1.DataSource
    '        Dim Item As BI.ExternalLib.FileService.DownLoadManager.Item = dr("Tag")
    '        Select Case e.Column.ColumnName
    '            Case "FileName"
    '                e.DisplayText = Item.Name
    '            Case "Size"
    '                Dim Value As Long = Item.TotalBytesToReceive
    '                If Value >= 1024 ^ 4 Then
    '                    e.DisplayText = Format(Value / 1024 ^ 4, "f") & " TB"
    '                ElseIf Value >= 1024 ^ 3 Then
    '                    e.DisplayText = Format(Value / 1024 ^ 3, "f") & " GB"
    '                ElseIf Value >= 1024 ^ 2 Then
    '                    e.DisplayText = Format(Value / 1024 ^ 2, "f") & " MB"
    '                Else
    '                    e.DisplayText = Format(Value / 1024 ^ 1, "f") & " KB"
    '                End If
    '            Case "State"
    '                e.DisplayText = System.Enum.GetName(GetType(BI.ExternalLib.FileService.StateModeEnum), Item.State)
    '            Case "Progress"
    '                If e.CellValue Is DBNull.Value Then
    '                    e.DisplayText = "0%"
    '                Else
    '                    Dim x As Integer = (e.Bounds.Width - 4) * CSng(e.CellValue / 100)
    '                    Using GradientBrush As New System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.FromArgb(122, 197, 255), Color.FromArgb(100, 122, 197, 255), 90)
    '                        e.Graphics.FillRectangle(GradientBrush, e.Bounds.X + 2, e.Bounds.Y + 2, x, e.Bounds.Height - 6)
    '                        e.Graphics.DrawRectangle(New Pen(Color.FromArgb(100, 197, 255), 1), e.Bounds.X + 2, e.Bounds.Y + 2, x, e.Bounds.Height - 6)
    '                    End Using
    '                    e.DisplayText = Format(e.CellValue / 100, "Percent")
    '                End If
    '        End Select
    '    End If
    'End Sub

    'Private Sub BDataGrid1_RowCellDoubleClick(sender As Object, e As Views.DataGrid.RowColEventArgs) Handles BDataGrid1.RowCellDoubleClick
    '    If e.Row("State") = BI.ExternalLib.FileService.StateModeEnum.成功 Then
    '        Dim Item As BI.ExternalLib.FileService.DownLoadManager.Item = e.Row("Tag")
    '        Dim Process As New Process
    '        Process.StartInfo.FileName = Item.LocalPath
    '        Process.Start()
    '    End If
    'End Sub

End Class